<?php
	include("../../include/dbconnect.php");
	extract($_POST);
	$strdk=" where id=$id";
	if($id=="") $strdk="";

	$table="hang";
	$table_title="hàng";
	$table_title_u="Hàng";

	session_start();
	header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
	echo "<$table>";
	if($_SESSION["un"]=="")
	{
		echo "<status>fail</status>";
		echo "<count>0</count>";
		echo "<message>Chưa đăng nhập !</message>";
	}
	else 
	{
		$result=mysql_query("select * from $table $strdk",$conn) or die("select * from $table $strdk");
		echo "<status>ok</status>";
		echo "<count>",mysql_num_rows($result),"</count>";
		echo "<message>OK</message>";	
		while($a=mysql_fetch_array($result))
		{
			echo "<row id='",$a["id"],"'>";
			echo "<cell>",$a["id"],"</cell>";//0
			echo "<cell><![CDATA[",$a["ten"],"]]></cell>";//1
			echo "<cell>",$a["idchungloai"],"</cell>";//2
			echo "<cell><![CDATA[",$a["mota"],"]]></cell>";//3
			echo "<cell>",$a["chophep"],"</cell>";//4
			echo "<cell><![CDATA[",$a["ngaytao"],"]]></cell>";//5
			echo "<cell><![CDATA[",$a["un"],"]]></cell>";//6
			$tencha="";
			$rs1=mysql_query("select * from chungloai where id=".$a["idchungloai"],$conn);
			while($a1=mysql_fetch_array($rs1)) $tencha=$a1["ten"];
			mysql_free_result($rs1);
			echo "<cell><![CDATA[",$tencha,"]]></cell>";//7
			echo "</row>";
		}
		mysql_free_result($result);
	}

	echo "</$table>";
	include("../../include/dbclose.php");
?>